local modid = 'webber_the_trainer'

local Widget = require 'widgets/widget'
local TEMPLATES = require "widgets/redux/templates"

local Text = require "widgets/text"

---@class widget_webbert_panel_item : widget_widget
---@overload fun(label:string,start_cost:integer,fn_click:function,fn_focus:function,fn_losefocus:function)
---@field label widget_text
---@field mid widget_imagebutton
---@field soul widget_text
---@field have widget_text
local webbert_panel_item = Class(Widget,
---@param self widget_webbert_panel_item
function(self,label,start_cost,fn_click,fn_focus,fn_losefocus)
    Widget._ctor(self, 'webbert_panel_item') -- 调用基类构造函数

    self.label = self:AddChild(Text(BODYTEXTFONT, 30 , label))

    self.mid = self:AddChild(TEMPLATES.StandardButton(function()
        if fn_click ~= nil then
            fn_click()
        end
    end , 'buy', {40,40}))
    self.mid:SetPosition(70,0)
    self.mid:SetOnGainFocus(function()
        if fn_focus ~= nil then
            fn_focus()
        end
    end)
    self.mid:SetOnLoseFocus(function()
        if fn_losefocus ~= nil then
            fn_losefocus()
        end
    end)

    self.soul = self:AddChild(Text(NUMBERFONT, 30 , start_cost))
    self.soul:SetPosition(248,0)
    self.soul:SetHAlign(ANCHOR_LEFT)
    self.soul:SetRegionSize(300,40)

    self.have = self:AddChild(Text(NUMBERFONT, 30 , '0'))
    self.have:SetPosition(50,0)
    self.have:SetHAlign(ANCHOR_LEFT)
    self.have:SetRegionSize(300,40)
end)


return webbert_panel_item